Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Skilavottord): Handle number plates and information about pre-deregistered vehicles #15878

Merged
merged 23 commits into from
Sep 11, 2024

Conversation

birkirkristmunds
Copy link
Member

@birkirkristmunds birkirkristmunds commented Sep 4, 2024

TS-866

What

Add number plates and use status info to Skilavottord web

Why

Samgöngustofa's request to add option for user to enter numberplate details when deregistering vehicles.

Screenshots / Gifs

image image image

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Introduced a new component, CarDetailsBox2, for enhanced vehicle detail management, focusing on vehicle ID, type, model year, owner, and mileage.
    • Added localization support for vehicle registration and number plate messages in both English and Icelandic.
    • Enhanced the Confirm component for vehicle deregistration with new vehicle status checks and improved form handling.
    • Added new methods for retrieving traffic and vehicle information from the Samgöngustofa API.
    • Updated the deRegisterVehicle method to accept a single VehicleModel object for improved data management.
  • Bug Fixes

    • Improved the robustness of the InlineError component by making the primary button optional.
  • Chores

    • Updated the database schema to track vehicle plate information, including counts and lost status.

Copy link
Contributor

coderabbitai bot commented Sep 4, 2024

Walkthrough

This pull request introduces significant changes across multiple components and services in the Skilavottord application. The CarDetailsBox component has been streamlined by removing mileage-related properties and logic, while a new CarDetailsBox2 component has been created to manage vehicle details, including mileage. Localization files have been updated to improve internationalization support. Additionally, service methods have been renamed or modified to accommodate the new vehicle information structure, enhancing overall vehicle data management.

Changes

File Change Summary
apps/skilavottord/web/components/CarDetailsBox/... Removed mileage-related props and logic; simplified component to focus on vehicle ID, type, model year, and owner.
apps/skilavottord/web/components/CarDetailsBox2/... Introduced a new component for displaying vehicle details, including mileage, using various UI elements and form controls.
apps/skilavottord/web/i18n/locales/en.json Added new localization entries for vehicle registration and number plates.
apps/skilavottord/web/i18n/locales/is.json Added Icelandic translations for new localization entries related to vehicle number plates.
apps/skilavottord/web/i18n/locales/translation.d.ts Introduced new interfaces for structured messaging related to vehicle number plates and deregistration events.
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/... Updated to use new GraphQL query and renamed mutation to accommodate additional vehicle information parameters.
apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js Added migration to modify the vehicle table, introducing plate_count and plate_lost columns.
apps/skilavottord/ws/src/app/modules/vehicle/... Added plateLost and plateCount properties to the VehicleModel class; renamed method to handle additional vehicle information parameters.
apps/skilavottord/ws/src/app/modules/recyclingRequest/... Modified deRegisterVehicle method to accept a VehicleModel object, enhancing encapsulation.
apps/skilavottord/ws/src/app/modules/samgongustofa/... Added getTraffic and getVehicleInformation methods for retrieving traffic and vehicle data.
apps/skilavottord/ws/src/app/modules/samgongustofa/transport/... Introduced TransportService for handling API interactions, including authentication and data retrieval.

Possibly related PRs

Suggested labels

automerge


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 25.75758% with 98 lines in your changes missing coverage. Please review.

Project coverage is 36.85%. Comparing base (b3af8c0) to head (7d45fc0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...dules/samgongustofa/transport/transport.service.ts 16.66% 35 Missing ⚠️
...app/modules/samgongustofa/samgongustofa.service.ts 27.27% 16 Missing ⚠️
...c/app/modules/samgongustofa/samgongustofa.model.ts 50.00% 10 Missing ⚠️
...dules/recyclingRequest/recyclingRequest.service.ts 18.18% 9 Missing ⚠️
...pp/modules/samgongustofa/samgongustofa.resolver.ts 0.00% 8 Missing ⚠️
...tord/ws/src/app/modules/vehicle/vehicle.service.ts 0.00% 4 Missing ⚠️
...ord/ws/src/app/modules/vehicle/vehicle.resolver.ts 0.00% 3 Missing ⚠️
...p/services/icelandicTransportAuthority.services.ts 50.00% 3 Missing ⚠️
.../src/app/modules/vehicle/vehicleAppSys.resolver.ts 0.00% 2 Missing ⚠️
...app/services/icelandicTransportAuthority.module.ts 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #15878    +/-   ##
========================================
  Coverage   36.84%   36.85%            
========================================
  Files        6709     6707     -2     
  Lines      137554   137441   -113     
  Branches    39103    39079    -24     
========================================
- Hits        50676    50648    -28     
+ Misses      86878    86793    -85     
Flag Coverage Δ
api 3.39% <ø> (ø)
application-system-api 41.69% <ø> (ø)
application-template-api-modules 23.48% <ø> (-0.02%) ⬇️
skilavottord-ws 24.34% <25.75%> (+0.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ottord/ws/src/app/modules/vehicle/vehicle.model.ts 76.66% <100.00%> (+1.66%) ⬆️
apps/skilavottord/ws/src/app/utils/const.ts 100.00% <100.00%> (ø)
...ules/recyclingRequest/recyclingRequest.resolver.ts 0.00% <0.00%> (ø)
.../app/modules/samgongustofa/samgongustofa.module.ts 0.00% <0.00%> (ø)
...s/src/app/modules/samgongustofa/transport/index.ts 0.00% <0.00%> (ø)
...skilavottord/ws/src/app/utils/skilavottordUtils.ts 50.00% <50.00%> (ø)
.../src/app/modules/vehicle/vehicleAppSys.resolver.ts 0.00% <0.00%> (ø)
...app/services/icelandicTransportAuthority.module.ts 0.00% <0.00%> (ø)
apps/skilavottord/ws/src/app/utils/index.ts 0.00% <0.00%> (ø)
...ord/ws/src/app/modules/vehicle/vehicle.resolver.ts 0.00% <0.00%> (ø)
... and 7 more

... and 17 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3af8c0...7d45fc0. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Sep 4, 2024

Datadog Report

All test runs f91ead3 🔗

4 Total Test Services: 0 Failed, 4 Passed
⬆️ Test Sessions change in coverage: 1 increased (+0.98%), 5 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.97s 1 no change Link
application-system-api 0 0 0 111 2 3m 30.16s 1 no change Link
application-template-api-modules 0 0 0 109 0 1m 50.57s 1 no change Link
skilavottord-ws 0 0 0 1 0 19.87s 1 increased (+0.98%) Link

@birkirkristmunds birkirkristmunds changed the title feat(Skilavottord): Handle unregister vehicles feat(Skilavottord): Handle number plates and information about pre-deregistered vehicles Sep 9, 2024
@birkirkristmunds birkirkristmunds marked this pull request as ready for review September 9, 2024 14:16
@birkirkristmunds birkirkristmunds requested a review from a team as a code owner September 9, 2024 14:16
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

Outside diff range, codebase verification and nitpick comments (2)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (1)

Line range hint 4-277: Comprehensive Review of Confirm Component

The Confirm component is effectively structured to handle the vehicle deregistration process within the Skilavottord application. The use of GraphQL for data fetching and mutations is well-integrated, and the component's handling of form state and user interactions is robust.

Suggestions:

  1. GraphQL Integration: Ensure that all GraphQL queries and mutations are covered by appropriate error handling and loading states to prevent UI glitches and unhandled exceptions.
  2. Component Integration: The integration of CarDetailsBox2 is a good example of component reuse. Ensure that the props passed to CarDetailsBox2 are correctly managed and updated to reflect any changes in the parent component's state.
  3. Form Management: The use of FormProvider is commendable. Consider adding inline comments explaining the choice of form management techniques, especially for complex form structures.
  4. Error and Loading States: The handling of loading and error states is well-done. Consider customizing the error messages to be more descriptive based on the specific errors returned from the GraphQL operations.

Overall, the component is well-crafted with a clear focus on functionality and user experience. It should serve its purpose effectively in the Skilavottord application.

Tools
Biome

[error] 197-197: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1)

Line range hint 2-393: Comprehensive Review of SamgongustofaService Class

The SamgongustofaService class is effectively structured to handle traffic and vehicle information retrieval for the Skilavottord application. The new methods getTraffic and getVehicleInformation are well-implemented, using modern asynchronous patterns and robust error handling.

Suggestions:

  1. Method Implementation: The new methods are correctly implemented with comprehensive error handling. Ensure that all possible error scenarios are considered and handled appropriately.
  2. Deprecation: The deprecation of getUserVehicle is clearly marked. Ensure that the documentation is updated to reflect this change and guide users towards the new methods.
  3. Error Handling: The error messages are descriptive and helpful for debugging. Consider centralizing error handling if similar patterns are used across multiple methods to reduce code duplication and improve maintainability.
  4. Service Structure: The class is well-organized with clear method names and structured logic. Consider adding more inline comments explaining the logic behind complex operations, especially in the XML parsing sections.

Overall, the class is well-crafted with a clear focus on functionality and robustness. It should serve its purpose effectively in managing traffic and vehicle information retrieval for the Skilavottord application.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3aa0c69 and 8018de0.

Files selected for processing (26)
  • apps/skilavottord/web/components/CarDetailsBox/CarDetailsBox.tsx (2 hunks)
  • apps/skilavottord/web/components/CarDetailsBox2/CarDetailsBox2.tsx (1 hunks)
  • apps/skilavottord/web/components/CarDetailsBox2/index.ts (1 hunks)
  • apps/skilavottord/web/components/InlineError/InlineError.tsx (2 hunks)
  • apps/skilavottord/web/components/index.ts (1 hunks)
  • apps/skilavottord/web/i18n/locales/en.json (1 hunks)
  • apps/skilavottord/web/i18n/locales/is.json (1 hunks)
  • apps/skilavottord/web/i18n/locales/translation.d.ts (1 hunks)
  • apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (11 hunks)
  • apps/skilavottord/web/utils/consts.ts (1 hunks)
  • apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js (1 hunks)
  • apps/skilavottord/ws/src/app/const.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.resolver.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.service.ts (5 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.model.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.module.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.resolver.ts (2 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (3 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/test/samgongustofa.service.spec.ts (2 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/transport/index.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/samgongustofa/transport/transport.service.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/vehicle/vehicle.model.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/vehicle/vehicle.resolver.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts (1 hunks)
  • apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.module.ts (1 hunks)
  • apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.services.ts (2 hunks)
Files skipped from review due to trivial changes (4)
  • apps/skilavottord/web/components/CarDetailsBox/CarDetailsBox.tsx
  • apps/skilavottord/web/components/CarDetailsBox2/index.ts
  • apps/skilavottord/ws/src/app/const.ts
  • apps/skilavottord/ws/src/app/modules/samgongustofa/transport/index.ts
Additional context used
Path-based instructions (22)
apps/skilavottord/web/utils/consts.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.module.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.module.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/components/index.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.resolver.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/components/InlineError/InlineError.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.model.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/vehicle/vehicle.model.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.services.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/test/samgongustofa.service.spec.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/vehicle/vehicle.resolver.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/transport/transport.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.resolver.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/components/CarDetailsBox2/CarDetailsBox2.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/i18n/locales/en.json (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/i18n/locales/is.json (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/web/i18n/locales/translation.d.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts

[error] 73-73: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.resolver.ts

[error] 82-82: This code is unreachable

... because this statement will throw an exception beforehand

(lint/correctness/noUnreachable)

apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx

[error] 197-197: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 270-271: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (22)
apps/skilavottord/web/utils/consts.ts (3)

3-5: Enum PlateInfo is well-defined.

The definition of PlateInfo with the member PLATE_LOST is clear and serves its intended purpose effectively.


7-9: Enum UseStatus is well-defined.

The definition of UseStatus with the member OUT_TICKET is clear, and the comment provides useful context for non-Icelandic speakers.


11-14: Enum OutInUsage is well-defined.

The definition of OutInUsage with members OUT and IN is clear and effectively represents binary states.

apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.module.ts (1)

8-12: Proper use of dependency injection in NestJS.

The addition of TransportService to the providers array is correctly implemented and follows NestJS best practices for enhancing module functionality.

apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.module.ts (1)

4-8: Review of module imports and configuration.

The addition of SamgongustofaModule using forwardRef is appropriate for handling potential circular dependencies within the NestJS application. This change allows IcelandicTransportAuthorityModule to utilize services or components provided by SamgongustofaModule, which is crucial for the new functionality related to handling number plates and pre-deregistered vehicles.

Ensure that the SamgongustofaModule is properly configured and does not introduce any unresolved dependencies or circular references that could affect the application's stability.

Run the following script to verify the module configuration and ensure no circular dependencies are introduced:

Also applies to: 15-15

Verification successful

No Circular Dependencies Detected Between SamgongustofaModule and IcelandicTransportAuthorityModule

The verification shows that IcelandicTransportAuthorityModule is not imported within SamgongustofaModule, indicating no circular dependencies between these modules. The configuration appears stable with respect to the changes made.

  • IcelandicTransportAuthorityModule is imported in recyclingRequest.module.ts, which does not affect the circular dependency concern.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential circular dependencies involving SamgongustofaModule.

# Test: Search for imports of IcelandicTransportAuthorityModule in SamgongustofaModule.
rg --type typescript -A 5 $'import { IcelandicTransportAuthorityModule }' apps/skilavottord/ws/src/app/modules

Length of output: 247


Script:

#!/bin/bash
# Description: Check for potential circular dependencies involving SamgongustofaModule.

# Test: Search for imports of IcelandicTransportAuthorityModule in SamgongustofaModule.
rg --type typescript -A 5 'import { IcelandicTransportAuthorityModule }' apps/skilavottord/ws/src/app/modules

Length of output: 247


Script:

#!/bin/bash
# Description: Check for potential circular dependencies involving SamgongustofaModule.

# Test: Search for imports of IcelandicTransportAuthorityModule in SamgongustofaModule.
rg --type typescript -A 5 'import \{ IcelandicTransportAuthorityModule \}' apps/skilavottord/ws/src/app/modules

Length of output: 148


Script:

#!/bin/bash
# Description: Check for potential circular dependencies involving SamgongustofaModule.

# Test: Search for imports of IcelandicTransportAuthorityModule in SamgongustofaModule.
rg --type ts -A 5 'import \{ IcelandicTransportAuthorityModule \}' apps/skilavottord/ws/src/app/modules

Length of output: 752

apps/skilavottord/web/components/index.ts (1)

16-16: Review of new component export.

The export statement for CarDetailsBox2 is correctly formatted and follows the established pattern of exporting components in this file. This addition enhances the component library, allowing for its use across the application.

Ensure that CarDetailsBox2 is accompanied by appropriate documentation and tests, especially since it plays a crucial role in handling new vehicle-related functionalities.

Run the following script to verify that CarDetailsBox2 is properly documented and tested:

apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.resolver.ts (1)

18-24: Review of new GraphQL query method.

The addition of the skilavottordTraffic method is correctly implemented with appropriate use of the @Query decorator and parameter decorators like @Args and @CurrentUser. This method enhances the resolver's functionality by allowing it to fetch traffic information based on the permno argument, which is crucial for the new feature related to handling traffic data.

Ensure that this method is secured against unauthorized access and is thoroughly tested to handle various edge cases and potential errors in data retrieval.

Run the following script to verify the security and testing of the skilavottordTraffic method:

apps/skilavottord/web/components/InlineError/InlineError.tsx (2)

7-7: Approved: Optional primaryButton property.

The change to make primaryButton optional enhances the component's flexibility and is correctly implemented in TypeScript.


43-50: Approved: Conditional rendering of primaryButton.

The conditional rendering logic for primaryButton is a best practice in React to ensure components handle optional props gracefully.

apps/skilavottord/ws/src/app/modules/samgongustofa/samgongustofa.model.ts (2)

50-70: Approved: New VehicleInformationMini class.

The VehicleInformationMini class is well-structured and appropriately uses GraphQL decorators to expose vehicle information. This addition should enhance the application's data handling capabilities.


72-102: Approved: New Traffic class.

The Traffic class is correctly structured and uses GraphQL decorators effectively to expose detailed traffic information. This addition enhances the module's functionality and data handling.

apps/skilavottord/ws/src/app/modules/vehicle/vehicle.model.ts (2)

84-88: Approved: plateLost property addition.

The addition of the plateLost property is well-implemented, using appropriate GraphQL and Sequelize decorators to handle nullable boolean data. This enhances the model's functionality by allowing it to store additional relevant information.


90-94: Approved: plateCount property addition.

The plateCount property is correctly implemented with GraphQL and Sequelize decorators to handle nullable integer data. This addition allows the model to store additional information about the number of plates, enhancing its data handling capabilities.

apps/skilavottord/ws/src/app/services/icelandicTransportAuthority.services.ts (1)

Line range hint 17-51: Refine error handling and enhance logging for better clarity and troubleshooting.

The method checkIfCurrentUser has been significantly refactored to return detailed vehicle information, which aligns well with the PR's objectives. However, the error handling could be more descriptive. Consider including more details in the error messages to aid in troubleshooting, especially in a production environment where clarity is crucial.

Additionally, the logging statements could be enhanced to provide more context about the errors, such as the specific reasons for the failures or the state of the data when the error occurred.

Consider the following improvements:

  1. Enhanced Error Messages:

    • Include specific details about what went wrong and possibly why.
    • Use structured logging to include additional context, such as permno and any relevant state information.
  2. Logging Improvements:

    • Use different log levels appropriately (e.g., info, warn, error) to differentiate the severity of the log messages.
    • Ensure that logs that could help in diagnosing issues are comprehensive and informative.

Here is a proposed change for the error handling:

- logger.error(
-   `car-recycling: Failed to get current owner info in checkIfCurrentUser when deregistering vehicle  ${permno.slice(-3)}`,
- )
- throw new Error(
-   'car-recycling: Failed to get current owner info in checkIfCurrentUser when deregistering vehicle',
- )

+ logger.error(
+   `car-recycling: Failed to get current owner info for vehicle ${permno}, no data available.`,
+   { permno, error: 'NoDataAvailable' }
+ )
+ throw new Error(
+   `car-recycling: No current owner data available for vehicle ${permno}. Please verify the vehicle's registration status.`
+ )
Tools
Biome

[error] 21-21: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

apps/skilavottord/ws/src/app/modules/vehicle/vehicle.resolver.ts (1)

107-119: Ensure proper integration of new parameters in updateSkilavottordVehicleInfo.

The method updateSkilavottordVehicleInfo has been updated to handle additional vehicle-related data, which is a significant change. It's crucial to ensure that these new parameters (plateCount and plateLost) are integrated properly throughout the system. This includes updating any related documentation, ensuring that all calls to this method are updated to pass the new parameters, and verifying that the backend logic correctly processes these parameters.

Consider verifying the integration of these parameters with a script:

Verification successful

Integration of new parameters in updateSkilavottordVehicleInfo is correct.

The method updateSkilavottordVehicleInfo has been updated to include the new parameters plateCount and plateLost, and these parameters are correctly used in the GraphQL mutation within Confirm.tsx. This indicates that the changes have been properly integrated into the codebase.

  • File: apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx
  • Mutation: updateSkilavottordVehicleInfo includes plateCount and plateLost.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `updateSkilavottordVehicleInfo` include the new parameters.

# Test: Search for the function usage. Expect: Only occurrences with the new parameters.
rg --type typescript -A 5 $'updateSkilavottordVehicleInfo'

Length of output: 92


Script:

#!/bin/bash
# Description: Verify all function calls to `updateSkilavottordVehicleInfo` include the new parameters.

# Test: Search for the function usage. Expect: Only occurrences with the new parameters.
rg --type ts -A 5 $'updateSkilavottordVehicleInfo'

Length of output: 1773

apps/skilavottord/web/i18n/locales/en.json (1)

332-348: New localization entries for number plates are clear and comprehensive.

  • The added entries under the "numberplate" key provide detailed information and instructions related to the handling of number plates during the vehicle deregistration process.
  • The structure and clarity of the messages are appropriate, ensuring that users receive understandable and actionable information.
apps/skilavottord/web/i18n/locales/is.json (1)

332-348: New Icelandic localization entries for number plates are accurately translated and appropriate.

  • The entries under the "numberplate" key are well-translated, providing Icelandic users with clear and relevant information regarding number plates.
  • The consistency with the English version ensures uniformity in information across languages, which is crucial for a bilingual application.
apps/skilavottord/web/i18n/locales/translation.d.ts (4)

276-277: Review of the modified Deregister interface.

The modification to include numberplate: NumberPlate in the Deregister interface aligns with the PR objectives to handle number plates for vehicles. This change is crucial for integrating the new functionality into the existing data model.


279-285: Review of the new NumberPlate interface.

The NumberPlate interface is well-defined with properties that are relevant to the vehicle deregistration process, such as sectionTitle, alert, count, lost, and missingInfo. This structure supports the new feature's requirements effectively.


287-289: Review of the new DeregisteredMessages interface.

The DeregisteredMessages interface, which includes info and warning properties of type Message, is appropriately structured to handle different types of messages related to the deregistration process. This addition enhances the application's ability to provide feedback to users during the deregistration process.


291-293: Review of the new Message interface.

The Message interface is simple and effective, providing a clear format for messages with title and message properties. This interface will facilitate the display of structured messages in the UI, which is essential for good user experience.

apps/skilavottord/ws/src/app/modules/samgongustofa/test/samgongustofa.service.spec.ts (1)

13-13: Confirm the necessity and implementation of TransportService.

The addition of TransportService to the test setup is noted. Ensure that this service is essential for the SamgongustofaService tests and that the mock implementation covers all necessary functionalities for comprehensive testing.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (3)
apps/skilavottord/ws/migrations/20231113210715-addcolumn-mileage.js (1)

Line range hint 1-12: Consider re-adding strict mode for safer JavaScript execution.

The removal of the 'use strict' directive can lead to less predictable behavior due to lenient parsing and error handling. While this specific migration script may not be directly affected due to its simplicity, maintaining strict mode is generally a good practice to prevent potential issues in more complex scenarios.

apps/skilavottord/ws/migrations/20220318210715-alow-null-recycling-partners.js (1)

Line range hint 1-12: Consider re-adding strict mode for safer JavaScript execution.

Removing 'use strict' simplifies the code but may lead to potential issues with variable scoping and error handling. Reintroducing strict mode could help avoid such issues and ensure that the script behaves as expected under various conditions.

apps/skilavottord/ws/migrations/20211207210715-access-control.js (1)

Line range hint 1-22: Consider re-adding strict mode for safer JavaScript execution.

The removal of 'use strict' directive from this migration script could potentially lead to issues with variable declarations and error handling. Given that this script handles database schema changes, maintaining strict mode would provide an additional layer of safety against JavaScript errors.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8018de0 and ee01473.

Files selected for processing (14)
  • apps/skilavottord/ws/migrations/20201008200611-vehicle_owner.js (1 hunks)
  • apps/skilavottord/ws/migrations/20201008210611-vehicle.js (1 hunks)
  • apps/skilavottord/ws/migrations/20201008210711-recycling-partners.js (1 hunks)
  • apps/skilavottord/ws/migrations/20201008220611-recycling_request.js (1 hunks)
  • apps/skilavottord/ws/migrations/20201008230611-gdpr.js (1 hunks)
  • apps/skilavottord/ws/migrations/20211207210715-access-control.js (1 hunks)
  • apps/skilavottord/ws/migrations/20220318210711-addcolumn-recycling-partners.js (1 hunks)
  • apps/skilavottord/ws/migrations/20220318210715-addcolumn-access-control.js (1 hunks)
  • apps/skilavottord/ws/migrations/20220318210715-alow-null-recycling-partners.js (1 hunks)
  • apps/skilavottord/ws/migrations/20231113210715-addcolumn-mileage.js (1 hunks)
  • apps/skilavottord/ws/migrations/20240307280301-add-indexes.js (1 hunks)
  • apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js (1 hunks)
  • apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.resolver.ts (1 hunks)
  • apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts (1 hunks)
Files skipped from review due to trivial changes (6)
  • apps/skilavottord/ws/migrations/20201008200611-vehicle_owner.js
  • apps/skilavottord/ws/migrations/20201008210611-vehicle.js
  • apps/skilavottord/ws/migrations/20201008210711-recycling-partners.js
  • apps/skilavottord/ws/migrations/20201008220611-recycling_request.js
  • apps/skilavottord/ws/migrations/20220318210711-addcolumn-recycling-partners.js
  • apps/skilavottord/ws/migrations/20220318210715-addcolumn-access-control.js
Files skipped from review as they are similar to previous changes (1)
  • apps/skilavottord/ws/migrations/202409083210715-addcolumns-numberplate-info.js
Additional context used
Path-based instructions (7)
apps/skilavottord/ws/migrations/20231113210715-addcolumn-mileage.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/migrations/20220318210715-alow-null-recycling-partners.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/migrations/20211207210715-access-control.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/migrations/20240307280301-add-indexes.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/migrations/20201008230611-gdpr.js (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/skilavottord/ws/src/app/modules/recyclingRequest/recyclingRequest.resolver.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Additional comments not posted (3)
apps/skilavottord/ws/migrations/20240307280301-add-indexes.js (1)

Line range hint 1-17: Confirm SQL command correctness and consider the implications of strict mode removal.

The SQL commands for creating and dropping indexes are correctly formatted and appear to be logically correct. However, the removal of 'use strict' could potentially affect the script's behavior by allowing more lenient error handling and variable usage. It's recommended to verify the script's behavior in a development environment to ensure no unintended side effects occur.

apps/skilavottord/ws/migrations/20201008230611-gdpr.js (1)

Line range hint 1-28: Confirm SQL command correctness and consider the implications of strict mode removal.

The SQL commands for creating and dropping the GDPR table are correctly formatted and appear to be logically correct. However, the removal of 'use strict' could potentially affect the script's behavior by allowing more lenient error handling and variable usage. It's recommended to verify the script's behavior in a development environment to ensure no unintended side effects occur.

apps/skilavottord/ws/src/app/modules/vehicle/vehicle.service.ts (1)

63-83: Review the expanded functionality in updateVehicleInfo.

The method updateVehicleInfo has been significantly modified to handle additional vehicle information, including plateCount and plateLost. The implementation correctly defaults values and updates the vehicle model accordingly. The error handling and logging have been enhanced to provide more detailed error messages, which improves the clarity and maintainability of the code.

The simplification of the boolean assignment for plateLost as suggested in previous comments has been correctly implemented, enhancing code readability and efficiency.

Copy link
Member

@veronikasif veronikasif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@birkirkristmunds birkirkristmunds added the automerge Merge this PR as soon as all checks pass label Sep 10, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4718dfa and 93bd06e.

Files selected for processing (1)
  • apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (11 hunks)
Additional context used
Path-based instructions (1)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
Biome
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx

[error] 199-199: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)


[error] 272-273: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (5)
apps/skilavottord/web/screens/DeregisterVehicle/Confirm/Confirm.tsx (5)

21-21: LGTM!

The change from CarDetailsBox to CarDetailsBox2 is consistent with the AI-generated summary and appears to be intentional. The code changes are approved.


37-38: LGTM!

The imports of FormProvider, useForm, and OutInUsage are used in the component and do not introduce any issues. The code changes are approved.


54-63: LGTM!

The addition of the SkilavottordTrafficQuery is consistent with the AI-generated summary and is used to fetch vehicle status information. The query is well-structured and does not introduce any issues. The code changes are approved.


85-97: LGTM!

The renaming of the mutation to UpdateSkilavottordVehicleInfoMutation and the addition of plateCount and plateLost fields are consistent with the AI-generated summary and the list of alterations. The changes are well-structured and do not introduce any issues. The code changes are approved.


102-105: LGTM!

The changes related to form handling, vehicle status integration, and mutation calls are consistent with the AI-generated summary and the list of alterations. The code segments are well-structured, follow best practices for NextJS and TypeScript, and do not introduce any issues. The code changes are approved.

Also applies to: 118-119, 130-145, 185-208, 266-279, 283-283

@birkirkristmunds birkirkristmunds removed the automerge Merge this PR as soon as all checks pass label Sep 11, 2024
@birkirkristmunds birkirkristmunds added the automerge Merge this PR as soon as all checks pass label Sep 11, 2024
@kodiakhq kodiakhq bot merged commit 72fc394 into main Sep 11, 2024
40 checks passed
@kodiakhq kodiakhq bot deleted the feat/skilavottord-handle-unregister-vehicles branch September 11, 2024 15:38
jonnigs pushed a commit that referenced this pull request Sep 12, 2024
…registered vehicles (#15878)

* TS-866 Rough first implementation

* TS-866 Implemented Samgöngustofa Traffic REST call.

* TS-866 Fix unit test

* TS-866 Continue working
- Translations
- UI

* TS-866 Remove deregister column

* TS-866 Fixing wrong data sent to Samgöngustofu

* TS-866 Fixing show right alert box and hide selection box

* TS-866 Refactoring code

* TS-866 Fix after Coderabbit review

* TS-866 Fix after Coderabbit review

* TS-866 Fix after Coderabbit review

* TS-866 Fix after Coderabbit review

* TS-866 Code refactoring

* TS-866 Removed checkbox blue background

* TS-866 Fix 0 mileage

* TS-866 Fix after coderabbit review

* TS-866 Add back owner

* TS-866 improve logging

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants